<template>
  <!-- 热门历史 -->
  <div>
    <div class="his-hot" v-show="isHistory">
      <div class="hd">
        <h4>历史记录</h4>
        <van-icon name="delete-o" @click="clear" />
      </div>
      <div class="bd">
        <van-tag
          @click="TagClick(item)"
          plain
          type="primary"
          v-for="(item, index) in historyKeywordList"
          :key="index"
          >{{ item }}</van-tag
        >
      </div>
    </div>
    <div class="his-hot">
      <div class="hd">
        <h4>热门搜索</h4>
      </div>
      <div class="bd">
        <van-tag
          @click="TagClick(item.keyword)"
          :class="item.is_hot == 1 ? 'red' : ''"
          plain
          type="primary"
          v-for="(item, index) in hotKeywordList"
          :key="index"
          >{{ item.keyword }}}</van-tag
        >
      </div>
    </div>
  </div>
</template>

<script>
import { clearHisttotySearch } from "@/request/api";
export default {
  data() {
    return {
      isHistory: true,
    };
  },
  methods: {
    //历史记录的点击搜索事件
    TagClick(val) {
      this.$emit("onSearch", val);
    },
    clear() {
      clearHisttotySearch().then((res) => {
        console.log(res);
        this.$toast.success("成功文案");
        setTimeout(() => {
          this.isHistory = false;
        }, 1000);
      });
    },
  },
  props: ["historyKeywordList", "hotKeywordList"],
};
</script>
 
<style lang = "less" scoped>
.his-hot {
  background-color: #fff;
  padding: 0.1rem 0.1rem 0;
  margin-bottom: 0.2rem;
  .hd {
    display: flex;
    justify-content: space-between;
    font-size: 0.2rem;
    font-weight: 100;
    margin-bottom: 0.1rem;
  }

  .van-tag {
    margin-right: 0.1rem;
    padding: 0.01rem 0.03rem;
    color: #ccc;
    margin-bottom: 0.1rem;
  }
  .red {
    color: darkred;
  }
}
</style>